/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package testconnnection;

/**
 *
 * @author house
 */
import java.sql.*;

    public class Testconnection {

    static String bd = "mydb";
    static String login = "root";

    static String password = "elikan";
    static String url = "jdbc:mysql://localhost/"+bd;

public static void main(String[] args) throws Exception {

    Connection conn = null;

    try {

    Class.forName("com.mysql.jdbc.Driver").newInstance();

    conn = DriverManager.getConnection(url,login,password);

    if (conn != null) {

    System.out.println("Conexión a base de datos "+url+" ... Ok");
    conn.close();
        }

    }

    catch(SQLException ex) {

    System.out.println("Hubo un problema al intentar conectarse con la base de datos "+url);
    }

    catch(ClassNotFoundException ex) {

    System.out.println(ex);
        }


    }

}